import matplotlib.pyplot as plt
import numpy as np
def f(x):
return x**5-3*x**4-5*x**3+x**2+x+3
if __name__=="__main__":
a=-2.0
b=4.0
lim=[[-2, 0], [0, 4]]
sol=[]
for ran in lim:
delta=1.0e-6
err=1.
a=ran[0]; b=ran[1]
while(err>delta):
x=(a+b)/2
if f(a)*f(x)<=0:
b=x
else:
a=x
err=np.abs(a-b)
sol.append(x)
print("Solution x:", sol[0], "and", sol[1])